package com.wwlwxg.jpa.controller;

import com.wwlwxg.jpa.entity.User;
import com.wwlwxg.jpa.repository.UserRepository;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class UserController {

  @Resource
  private UserRepository userRepository;

  @GetMapping("/user/{id}")
  public User getUser(@PathVariable("id") Integer id) {
    User user = userRepository.getById(id);
    return user;
  }

  @GetMapping("/user")
  public User insertUser(User user) {
    User save = userRepository.save(user);
    return save;
  }

}
